#region Imports

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using MetaSapiens.PageMethods;

#endregion

/// <summary>
/// Page that displays the list of customers.
/// </summary>
public partial class ListCustomer : MetaSapiens.PageMethods.BasePageWithDefaultMethod
{
  /// <summary>
  /// Displays the customers.
  /// </summary>
  [PageMethod(true)]
  public void Display()
  {
    CustomerData dataSet;

    dataSet = new CustomerData();
    dataSet.Customer.AddCustomerRow(1, "Un");
    dataSet.Customer.AddCustomerRow(2, "Deux");

    DataList1.DataSource = dataSet.Customer;

    DataBind();
  }

  protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
  {
    HyperLink lnkCustomer;
    CustomerData.CustomerRow row;

    if ((e.Item.ItemType != ListItemType.AlternatingItem) &&
        (e.Item.ItemType != ListItemType.EditItem) &&
        (e.Item.ItemType != ListItemType.Item) &&
        (e.Item.ItemType != ListItemType.SelectedItem))
      return;

    row = (CustomerData.CustomerRow)((DataRowView)e.Item.DataItem).Row;
    lnkCustomer = (HyperLink)e.Item.FindControl("lnkCustomer");
    lnkCustomer.Text = row.Name;
    lnkCustomer.NavigateUrl = MyPageMethods.Customers.FrmCustomer.DisplayCustomer(row.CustID);
  }
}